home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvitovdu32 / src / pascal / screenio.h < prev    next >
Text File  |  1991-11-10  |  2KB  |  55 lines

  1. (* These terminal i/o routines are highly system-dependent and have been
  2.    designed for DVItoVDU and its auxiliary modules.
  3.  
  4.    Notes:
  5.  - InitScreenIO saves the current tty characteristics,
  6.    then sets the mode to cbreak with no echo.
  7.    Clients should therefore call RestoreTerminal before terminating.
  8.  - WriteBuffer or WriteLine must be called to explicitly update the terminal
  9.    (e.g., just before a read) or to synchronize output with writes
  10.    from other modules that don't use ScreenIO.
  11.  - WriteString assumes the end of a string is the first blank (if not full),
  12.    so clients need to replace calls like WriteString('xxx = ') with
  13.    WriteString('xxx ='); WriteChar(' ').
  14. *)
  15.  
  16. CONST
  17.    maxbufsize  = 128;   (* size of output buffer *)
  18.    maxbufsizem = maxbufsize - 1;
  19.  
  20.    CR    = CHR(10);     (* SYSDEP: char read upon hitting Return key *)
  21.    CTRLC = CHR(0);      (* SYSDEP: interrupt, see unixio *)
  22.    CTRLZ = CHR(1);      (* SYSDEP: suspend, see unixio *)
  23.    (* SYSDEP: unixio puts CTRLC and CTRLZ into input buffer (along with CR)
  24.       upon getting a ^C or ^Z interrupt.
  25.       (It can't put CHR(3) and CHR(26) into buffer
  26.       because tty will detect another interrupt and we'll loop forever!)
  27.    *)
  28.    NUL = CHR(  0b);
  29.    FF  = CHR( 14b);
  30.    CAN = CHR( 30b);
  31.    ESC = CHR( 33b);
  32.    FS  = CHR( 34b);
  33.    GS  = CHR( 35b);
  34.    US  = CHR( 37b);
  35.    XXX = CHR(377b);
  36.  
  37. TYPE
  38.    screenbuf = PACKED ARRAY [0..maxbufsizem] OF CHAR;
  39.  
  40. VAR
  41.    buf    : screenbuf;                        (* terminal output buffer *)
  42.    buflen : 0..maxbufsize;                    (* chars in output buffer *)
  43.    TeXtoASCII : ARRAY [NUL..XXX] OF CHAR;     (* TeX char to ASCII char *)
  44.  
  45. PROCEDURE InitScreenIO;                         EXTERNAL;
  46. PROCEDURE ReadChar (VAR ch : CHAR);             EXTERNAL;
  47. PROCEDURE ReadString (VAR s : string);          EXTERNAL;
  48. FUNCTION  BusyRead (VAR ch : CHAR) : BOOLEAN;   EXTERNAL;
  49. PROCEDURE WriteChar (ch: CHAR);                 EXTERNAL;
  50. PROCEDURE WriteString (s: string);              EXTERNAL;
  51. PROCEDURE WriteInt (i : INTEGER);               EXTERNAL;
  52. PROCEDURE WriteLine;                            EXTERNAL;
  53. PROCEDURE WriteBuffer;                          EXTERNAL;
  54. PROCEDURE RestoreTerminal;                      EXTERNAL;
  55.